<%@ page contentType="text/html;charset=UTF-8" language="java"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="/jstl/fn" prefix="fn"%>
<!DOCTYPE html>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport"
	content="width=device-width,initial-scale=1 user-scalable=0">
<title>发布</title>
<link rel="stylesheet" href="<%=basePath%>assets/css/page.css">
<link rel="stylesheet" href="<%=basePath%>/assets/css/public.css">
<script src="<%=basePath%>/assets/js/jquery-1.8.3.min.js"></script>
<script src="<%=basePath%>/assets/js/fontSize.js"></script>
<link href="<%=basePath%>/assets/layer/mobile/need/layer.css"
	rel="stylesheet" type="text/css">
<script src="<%=basePath%>/assets/layer/mobile/layer.js"></script>
<link rel="stylesheet" href="<%=basePath%>/assets/imgTools/helmet.css">
<link rel="stylesheet"
	href="<%=basePath%>assets/font-awesome-4.7.0/css/font-awesome.min.css">
<link rel="stylesheet"
	href="<%=basePath%>/assets/noneOfCss/noneOfCss.css">
<style type="text/css">
body {
	padding-top: 1.6rem;
}

.dingdanriqi {
	width: 20%
}

.riqi_day {
	width: 100%;
	height: 1rem;
	font-size: 0.4rem;
	font-weight: bold;
	text-align: center;
	display: block;
	line-height: 1rem
}

.riqi_month {
	width: 100%;
	height: 1rem;
	font-size: 0.24rem;
	text-align: center;
	display: block
}

.dingdanneirong_title {
	font-size: 0.26rem;
	height: 0.6rem;
	line-height: 0.6rem
}

.dingdanneirong {
	width: 100%
}

.dingdanneirong>li {
	background: #fff;
	padding: 0.2rem;
}

.dingdanneirong>li:last-child {
	border-bottom: none
}

.dingdanxiangqing>img {
	width: 20%;
	float: left;
	height: 1.3rem
}

.dingdanxiangqing_text {
	width: 75%;
	padding-left: 3%;
	height: 0;
	padding-bottom: 22%;
}

.ddxq_text {
	font-size: 0.2rem;
	line-height: 0.4rem
}

.dingdanxiangqing_text>span {
	color: red;
}

.dingdanxiangqing_text>span i {
	font-size: 0.28rem;
	line-height: 0.6rem;
}

.bianjicaozuo, .shanchucaozuo, .calianganniu {
	font-size: 0.22rem;
	height: 0.42rem;
	line-height: 0.48rem;
	text-align: center;
	border: 1px solid #ccc;
	width: 1rem;
	float: right;
	border-radius: 0.1rem;
	margin-left: 0.1rem;
}

.ershouspmc {
	font-size: 0.24rem;
	font-weight: bold;
	white-space: nowrap;
	text-overflow: ellipsis;
	overflow: hidden;
	line-height: 0.45rem;
}

.ershouspjg {
	font-size: 0.22rem;
	line-height: 0.3rem;
	display: inherit
}

.ershouspfbsj {
	width: 30%;
	float: left;
	font-size: 0.18rem;
	line-height: 0.4rem;
}

.ershouspfbxinxi {
	font-size: 0.2rem;
	color: #a1a1a1;
	height: 0.4rem;
	line-height: 0.4rem;
}

.caliangsj {
	float: left;
	width: 35%;
	font-size: 0.22rem;
	height: 0.4rem;
	line-height: 0.4rem;
}

.caozuo {
	border-top: 1px solid #f1f1f1;
	margin-top: 0.2rem;
	padding-top: 0.2rem;
}

.dingdanxiangqing {
	position: relative;
}

.goods_img {
	width: 22%;
	height: 0;
	padding-bottom: 22%;
	background-size: 140%;
	background-position: 20% 20%;
	background-repeat: no-repeat;
	overflow: hidden;
	margin-top: 0;
	float: left;
	border-bottom: none;
}

.aside2 {
	display: none;
}
</style>
</head>
<body>
	<input type="hidden" value="<%=basePath%>" id="basePath">

	<div class="header">
		<a class="returnInfo" href="#" onclick="returnDescend()"> <i
			class="fa fa-angle-left"></i>
		</a> 我发布的 <a class="rightInfo" href="#"></a>
	</div>

	<div class="find_nav">
		<div class="find_nav_left">
			<div class="find_nav_list" id="pagenavi1">
				<ul>
					<li class="sell active"><a>我出售的</a></li>
					<li class="buy"><a>我求购的</a></li>
				</ul>
			</div>
		</div>
	</div>

	<div class="dingdan clearFirx aside1">
		<ul class="dingdanneirong float_l">
			<c:forEach var="thgList" items="${usedGoodsList}">
				<li class="clearFirx border-bottom-8">
					<div class="dingdanxiangqing clearFirx">
						<div class="goods_img" style="background-image: url(<%=basePath%>/app/getGoodsPhotoByName?goodsImage=${thgList.goodsThums});"
							onclick="toHandGoodsInfo(${thgList.goodsId})">
						</div>
						<div class="float_l dingdanxiangqing_text">
							<div onclick="toHandGoodsInfo(${thgList.goodsId})" class='ershouspmc'>${thgList.goodsName}</div>
							<span onclick="toHandGoodsInfo(${thgList.goodsId})" class="ershouspjg">￥<i>${thgList.goodsPrice}</i></span>
							<p class='ershouspfbxinxi'>留言${thgList.leaveMessageCount} · 浏览${thgList.pageView}</p>
						</div>
					</div>
					<div class='clearFirx caozuo'>
						<p class='caliangsj'></p>
						<div class='shanchucaozuo' onclick="delMyPush(${thgList.goodsId})">删除</div>
						<div class='calianganniu' onclick="goodsPolish(${thgList.goodsId})">擦亮</div>
					</div>
				</li>
			</c:forEach>
		</ul>
	</div>

	<div class="dingdan clearFirx aside2">
		<ul class="dingdanneirong float_l">
			<c:forEach var="buyList" items="${buyList}">
				<li class="clearFirx border-bottom-8">
					<div class="dingdanxiangqing clearFirx">
						<div class="goods_img"
							style="background-image: url(<%=basePath%>/app/getGoodsPhotoByName?goodsImage=${buyList.goodsThums});"
							onclick="toWantBuyDetail(${buyList.goodsId})"></div>
						<div class="float_l dingdanxiangqing_text">
							<div onclick="toWantBuyDetail(${buyList.goodsId})"
								class='ershouspmc'>求购${buyList.goodsName}</div>
							<span onclick="toWantBuyDetail(${buyList.goodsId})"
								class='ershouspjg'>￥<i>${buyList.goodsPrice}</i></span>
							<p class='ershouspfbxinxi'>留言${buyList.leaveMessageCount}·浏览${buyList.pageView}</p>
							<c:if test="${buyList.state != 0}">
							</c:if>
						</div>
					</div>
					<div class='clearFirx caozuo'>
						<p class='caliangsj'></p>
						<div class='shanchucaozuo' onclick="delMyPush(${buyList.goodsId})">删除</div>
						<div class='calianganniu'
							onclick="goodsPolish(${buyList.goodsId})">擦亮</div>
					</div>

				</li>
			</c:forEach>
		</ul>
	</div>

	<div class="noSJ" style="display: none; margin: 10% 0 0 0px;">
		<img src="<%=basePath%>assets/images/bcz.png" alt="">
		<h3 style="font-size: 1.17em;">目前没有您发布的二手商品~</h3>
	</div>
</body>
<script>
$(function () {
	$('.buy').click(function(){
		$('.aside1').hide();
		$('.aside2').show();
		$('.buy').addClass('active');
		$('.sell').removeClass('active')
	});
	$('.sell').click(function(){
		$('.aside2').hide();
		$('.aside1').show();
		$('.sell').addClass('active');
		$('.buy').removeClass('active')
	});
	var obj = "${usedGoodsList}";
	if(obj == "[]"){
		$(".noSJ").css("display","block");
	}
	var array = new Array();  
	<c:forEach items="${usedGoodsList}" var="usedGoods">  
		array.push("${usedGoods.updateDate}"); //js中可以使用此标签，将EL表达式中的值push到数组中  
	</c:forEach>  
	for(var i=0;i<array.length;i++)  
	{
		
		//时间比较
		var updateDate=new Date(array[i]);//开始时间
		var date = new Date();//当前时间
		var dateTime=date.getTime()-updateDate.getTime();//时间差秒
		//计算出相差天数
		var days=Math.floor(dateTime/(24*3600*1000));
		if(days < 1){
			$("ul li:eq("+i+") .calianganniu").text('已擦亮');
			$("ul li:eq("+i+") .calianganniu").css('color','#ccc');
			$("ul li:eq("+i+") .caliangsj").text('刚刚擦亮');
		}
	}  
	
	$('.dingdanneirong').find('li').each(function(){

		$(this).find('.calianganniu').click(function(){
			
			if($(this).text() == '擦亮'){
				$(this).text('已擦亮');
				$(this).css('color','#ccc');
				$(this).parent().find('.caliangsj').html("刚刚擦亮");
				
			}
		})
	})
});

//擦亮
function goodsPolish(goodsId){
	$.ajax({
    	url: $("#basePath").val()+"app/goodsPolish",
        type: 'post',
        data: {"goodsId":goodsId},
        dataType: 'json',
        success: function (data) {
        },error:function (){
        }
	});
};

//删除我的发布
function delMyPush(goodsId){
	$.ajax({
    	url: $("#basePath").val()+"app/delGoods",
        timeout: 300000,
        type: 'post',
        data: {"goodsId":goodsId},
        dataType: 'json',
        success: function (data) {
        	if(data.state==1){
      		  layer.open({
  			    content: '删除成功'
  			    ,skin: 'msg'
  			    ,time: 1 //2秒后自动关闭
  			  });
        		window.location.href=$("#basePath").val()+"app/toTwoHandPushList";
        	}else{
        		  layer.open({
        			    content: '删除失败'
        			    ,skin: 'msg'
        			    ,time: 1 //2秒后自动关闭
        			  });
        	}
        },error:function (){
        }
	});
};
//返回上一层
function returnDescend(){
	window.history.go(-1);
};
function toHandGoodsInfo(goodsId){
	window.location.href="<%=basePath%>app/getUsedGoodsInfo?goodsId="+goodsId;
}
function toWantBuyDetail(goodsId){
	window.location.href="<%=basePath%>app/getWantBuyDetail?goodsId="+goodsId;
}
</script>
</html>